home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / ASSEMBLE / H235A.ZIP / ASM_0_M.ZIP / DOORS2.ASM < prev    next >
Assembly Source File  |  1986-01-16  |  9KB  |  229 lines

  1. title     DOORS2.ASM
  2. comment ~
  3.       ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  4.      ╔════════════════════════════════════════════════╗█
  5.      ║               PCMagizine ASseMbler             ║█
  6.      ║                                                ║█
  7.      ║     The following program began its life in    ║█
  8.      ║     PC Magazine. A detailed description of     ║█
  9.      ║     the program can be found in the issue      ║█
  10.      ║     referenced below.                          ║█
  11.      ║                                                ║█
  12.      ╚════════════════════════════════════════════════╝▀
  13.  
  14.      DOORS.ASM     John Dickinson, "Try a Door, Not a Window"
  15.                Vol. 4, No. 3 (February  5, 1985)
  16.                Coordinating your color and monochrome
  17.                displays
  18.  
  19. The program becomes memory resident when run, and scans the
  20. keycodes of any keys pressed.  In its original version, if the
  21. Alt - Right Shift keys were pressed together, the routine would
  22. copy all screen information to the monitor not being used, and
  23. would switch to that monitor.
  24.  
  25. The program has been modified slightly.  Now, the Alt - Left Shift
  26. keys will switch monitors.  The Alt - Right Shift keys will copy
  27. all text information to the other screen, but leave you where you
  28. were on the original monitor.  (I use this function to put a
  29. "snapshot" of text on the other screen for reference while I work).
  30.  
  31. If the program is switching to the graphics board, it does so in
  32. the BW80 mode -- which can be changed to the CO80 mode (see the
  33. comments below) if you have a color monitor.
  34.  
  35. Modified January 1986.
  36.  
  37. Please let me know about any bugs/comments that you have via
  38. Gene Plantz' IBBS, 312-882-4227.
  39.                                                      Mike Pechnyo
  40.                                                      ID1206
  41.   ~
  42. ;
  43. ROM_BIOS_DATA     segment at 40h          ; Low Memory "BIOS" Parameters
  44. ;
  45.      org     10h             ; Location of EQUIP_FLAG
  46. EQUIP_FLAG   dw     ?        ; Contains video settings
  47.                              ; in bits 4 and 5
  48. ;
  49.      org     17h             ; Location of KB_FLAG
  50. KB_FLAG      db     ?        ; Contains Alt (bit 3) &
  51.                              ; Right Shift (bit 0) States
  52. ROM_BIOS_DATA     ends
  53. ;
  54. ; Initialization Routine
  55. ;
  56. CODE_SEG     segment
  57.      assume  cs:CODE_SEG
  58.      org     100h            ; COM program format
  59. BEGIN:     jmp     SWAP_VECTORS      ; Initialize vectors and attach to DOS
  60. ;
  61. ROM_KB_INT     dd     ?      ; Double word to save address of
  62.                              ; ROM-BIOS keyboard interrupt
  63. video_hold  dw 2000 dup(?)   ; storage to hold the old screen
  64. old_mode    db ?
  65.  
  66. ; DOORS_INT intercepts the keyboard interrupt and switches
  67. ;  screens if [Alt]-[Shift] combination is pressed
  68. ;
  69.  
  70. DOORS_INT     proc     near
  71.      assume     ds:nothing
  72.      push     ds             ; Push all affected registers
  73.      push     es
  74.      push     ax
  75.      push     bx
  76.      push     cx
  77.      push     dx
  78.      push     si
  79.      push     di
  80. ;
  81.      pushf                   ; Push Flags for fake interrupt call
  82.      call     ROM_KB_INT     ; to BIOS program to read keyboard
  83. ;
  84.      assume   ds:ROM_BIOS_DATA        ; Define data segment to read
  85.      mov      ax,ROM_BIOS_DATA        ; keyboard flag & equipment flag
  86.      mov      ds,ax
  87.      mov      cx,2            ; times to go through the loop
  88.      mov      al,KB_FLAG      ; Get keyboard flag
  89.      and      al,11           ; Isolate [Alt] + [Shift keys]
  90.      cmp      al,09           ; is [Alt] + [Right Shift] pressed ?
  91.      je       go_ahead
  92.      cmp      al,10           ; is [Alt] + [Left Shift] pressed ?
  93.      jne      RETURN          ; No, quit
  94.      mov      cx,1            ; set cx to 1 if Left Shift, 2 if Right Shift
  95.                               ; do 2 passes through the code if Right Shift
  96.                               ; (copy info to opposite screen), 1 pass if
  97.                               ; Left Shift (switch monitors)
  98. ;
  99. ; [Alt] + [Right Shift] are pressed -- Continue processing
  100. ; Check on video mode - quit if not monochrome, color 80x25 or BW 80x25
  101. ;
  102. go_ahead:
  103.                               ; first check the original screen mode
  104.      mov      ah,15           ; Call Func 15 of Int 10h to
  105.      int      10h             ; get video state of the PC
  106.      cmp      al,7            ; Is screen monochrome?
  107.      je       SCREEN_OKAY     ; Yes, go switch screens
  108.      cmp      al,3            ; Is screen color text?
  109.      jbe      CHECK_40_OR_80         ; Yes, go check for 80 or 40 char
  110.      jmp      RETURN          ; Screen is in graphics mode, quit
  111. CHECK_40_or_80:
  112.      cmp      al,1            ; Is screen 40-character?
  113.      jbe      RETURN          ; Yes, quit
  114. ;
  115. SCREEN_OKAY:
  116.      push     cx              ; save the number of times to do the work
  117.  
  118. ;
  119. ; Save the current cursor position
  120. ;
  121.      mov      ah,3            ; Call Func 3 of Int 10H
  122.      mov      bh,0            ; to read cursor position
  123.      int      10h             ; (page zero for color screen)
  124. ;
  125. ; Screen switch routine - Establish calling argument (AL) for Int 10h
  126. ;
  127.      mov      bx,EQUIP_FLAG   ; Current equipment flag to BX
  128.      mov      cx,bx           ; Make a copy of it in CX
  129.      and      cx,30h          ; Extract screen information
  130.      xor      bx,cx           ; Erase current screen information in BX
  131.      or       bx,20h          ; Set BX to color 80x25
  132.      mov      al,2            ; Set AL for B&W 80x25 in Int 10h
  133.                               ; change to 3 for color 80x25
  134.      cmp      cx,30h          ; Is current mono?
  135.      je       SET_MODE        ; Yes, switch to color
  136.      or       bx,30h          ; No, set BX for monochrome
  137.      mov      al,7            ; Set AL for monochrome in Int 10h
  138. SET_MODE:
  139.      mov      EQUIP_FLAG,bx   ; Write BX to equipment flag
  140.      xor      ah,ah           ; Use Func 0 of Int 10h to
  141.      int      10h             ; change screen parameters
  142. ;
  143. ; Restore Cursor
  144. ;
  145.      mov      ah,2            ; Use Func 2 of Int 10h to restore
  146.      mov      bh,0            ; cursor on new screen (position in DX)
  147.      int      10h
  148. ;
  149. ; After screens are switched, set DS and ES registers to move screen data
  150. ;
  151.      push     ds              ; save the data segment
  152.      mov      ax,0b000h       ; Load ES with Mono Segment
  153.      mov      es,ax
  154.      mov      ax,0b800h       ; Load DS with Color Segment
  155.      mov      ds,ax
  156.      cmp      cx,30h          ; Did we switch from mono?
  157.      jne      COPY_THE_SCREEN ; NO, move data from mono to color
  158.      push     ds              ; YES, swap ES and DS to move data
  159.      push     es              ; from mono to color
  160.      pop      ds
  161.      pop      es
  162. COPY_THE_SCREEN:
  163.      xor      di,di           ; Start at zero offsets
  164.      xor      si,si
  165.      mov      cx,2000         ; 2000 chars + attrs per screen
  166.      cld                      ; Make sure move is 'forward'
  167. rep     movsw                 ; Move Words with string instruction
  168.                               ; from DS:[SI] to ES:[DI]
  169.      pop      ds              ; restore the data segment
  170.  
  171.      pop      cx              ; restore the count value
  172.      loop     SCREEN_OKAY     ; and go back if CX>0
  173. ;
  174. RETURN:
  175.      pop      di              ; Restore saved registers
  176.      pop      si
  177.      pop      dx
  178.      pop      cx
  179.      pop      bx
  180.      pop      ax
  181.      pop      es
  182.      pop      ds
  183.      iret                     ; Return to system
  184.  
  185. DOORS_INT      endp
  186. ;
  187. ; This procedure initializes the new keyboard interupt vectors
  188. ;
  189. SWAP_VECTORS  proc     near
  190. ;     push     ds              ; Save Data Segment
  191.                               ; for DOS return
  192. comment |
  193.      mov     ax,VECTORS       ; Set up the data
  194.      mov     ds,ax             ; segment for vectors
  195.      cli                         ; Disable interrupts
  196.      mov     ax,word ptr KB_INT_VECTOR          ; Store addresses
  197.      mov     word ptr ROM_KB_INT,ax               ; of BIOS program
  198.      mov     ax,word ptr KB_INT_VECTOR[2]
  199.      mov     word ptr ROM_KB_INT[2],ax
  200.      mov     word ptr KB_INT_VECTOR, offset DOORS_INT ; Substitute Our
  201.      mov     word ptr KB_INT_VECTOR[2],cs          ; Program
  202.      sti                         ; Enable interrupts
  203.  
  204.      ; the old code (commented out) has been replaced by the
  205.      ; more kosher DOS 2.0 Get and Set interrupt calls -- of course,
  206.      ; this DOES require using DOS 2.0 or above  --  and the routine
  207.      ; does NOT check the DOS version
  208.   |
  209.      mov      ah,35h
  210.      mov      al,9                      ; keyboard function
  211.      int      21h                       ; get interrupt vector
  212.      mov      word ptr ROM_KB_INT,bx    ; offset
  213.      mov      word ptr ROM_KB_INT[2],es ; segment
  214.  
  215.      mov      ah,25h
  216.      mov      al,9
  217.      push     cs
  218.      pop      ds                        ; DS:DX point to this routine
  219.      mov      dx,offset DOORS_INT
  220.      int      21h                       ; set interrupt vector
  221.  
  222.      mov      dx,offset SWAP_VECTORS    ; End of new resident
  223.                                         ; program
  224.      int      27h                       ; Terminate resident
  225. SWAP_VECTORS     endp
  226. CODE_SEG     ends
  227.      end     BEGIN
  228. ;
  229.